package love.yuanmengrobot.attendancesystem.servlet;
/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:CHJY创幻
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/6/20 16:50
 */

import com.google.gson.Gson;
import love.yuanmengrobot.attendancesystem.dao.MemberDao;
import love.yuanmengrobot.attendancesystem.entity.Member;

import java.io.IOException;
import java.io.PrintWriter;

public class MemberServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String name = request.getParameter("name");
        String age = request.getParameter("age");
        String memberid=request.getParameter("memberid");
        MemberDao member=new MemberDao();
        Member member1 = member.queryById(memberid);
        PrintWriter pw = response.getWriter();
        pw.print(new Gson().toJson(member1));
//        pw.print("您使用GET方式请求该Servlet。<br />" + "name = " + name + ",age = " + age);
        pw.flush();
        pw.close();
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String name = request.getParameter("name");
        String age = request.getParameter("age");
        PrintWriter pw = response.getWriter();
        pw.print("您使用POST方式请求该Servlet。<br />" + "name = " + name + ",age = " + age);
        pw.flush();
        pw.close();
    }
}
